<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@include file="../../mytags.jsp" %>
<!DOCTYPE html>
<html>
<head>
    <t:base type="jquery"></t:base>
    <script type="text/javascript" src="webpage/com/wx/added_product/procurement/shoppingCar.js"></script>
    <meta charset="utf-8">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>

    <script type="text/javascript" charset="utf-8">
        mui.init();

    </script>
    <style>

        .inrr {
            float: none
        }

        .inr span {
            line-height: 40px;
        }

        .mui-input-clear {
            margin-bottom: 0px !important;
        }

        .mui-scroll-wrapper {
            position: relative;
            margin-top: 10px;
        }

        /*.invoice-select{
            background-color: ;
        }*/
    </style>
</head>
<body>
<div class="geren" style="font-weight: bold;margin-bottom: 10px;">
    <img src="${webRoot }/images/about.jpg">发票信息
</div>
<div class="kow ds">
    <div class="chanp chanpp zy" style="margin-top: 0; margin-bottom: 70px;">
            <div style="margin-top:10px;font-size:0.8em;padding-left:10px;color:#bcbebd">
            每人最多可填写10个发票信息
            <span class="a-addct" id="btn_confirm">增加发票信息</span>
        </div>
        <ul class="mui-table-view" id="zy-invoice-list" style="background-color: #F0F0F0">
            <c:forEach var="ct" items="${ordInvoice}">
                <li class="ct-choose mui-table-view-cell tag-c
            <c:if test="${ct.isDefault eq'1'}">
            tag-choose
            </c:if>
            <c:if test="${ct.isDefault ne'1'}">
            tag-unchoose
            </c:if>
            " style="margin-top:8px;padding-bottom:10px;" data-id="${ct.id}">
                    <div class="inrr" style="width:100%">
                        <%--<h4>--%>
                            <%--<span>发票类型</span><t:dictSelect field="invoiceGenre" type="span" defaultVal="${ct.invoiceGenre}" typeGroupCode="invoiceGenre"/>--%>
                            <div class="ct-tools1">
                                <span class="ct-edit" style="margin-right: 10px;">修改</span>
                                <%--<span class="ct-del">删除</span>--%>
                            </div>
                        <%--</h4>--%>
                        <%--<c:if test="${ct.invoiceGenre eq 'dedicated'}">--%>
                            <h4>
                                <span>税号</span>${ct.clientTaxnum}&nbsp;
                            </h4>
                            <h4>
                                <span>银行名称</span>${ct.clientBankname}&nbsp;
                            </h4>
                            <h4>
                                <span>银行账号</span>${ct.clientBankaccount}&nbsp;
                            </h4>
                            <h4>
                                <span>发票抬头</span>${ct.invoiceTitle}&nbsp;
                            </h4>
                        <%--</c:if>--%>
                        <%--<c:if test="${ct.invoiceGenre ne 'dedicated'}">--%>
                            <%--<h4>--%>
                                <%--<span>发票抬头</span>${ct.invoiceTitle}&nbsp;--%>
                            <%--</h4>--%>
                        <%--</c:if>--%>

                    </div>
                </li>
            </c:forEach>
        </ul>
    </div>
</div>
<script type="text/javascript">
    var defaultText = "默认发票",setDefault = "设为默认";

    function chooseInvoice(){
        var aid = localStorage.getItem(_Car.STORAGEKEY.selectedInvoice);
        if(aid != undefined && aid !=''){
            $(".tag-c").each(function(idx,itm){
                var o = $(this);
                if(o.attr("data-id") == aid){
                    $("li").removeClass("tag-choose tag-unchoose");
                    o.addClass("tag-choose");
                    $("li").not(o).addClass("tag-unchoose");
                    return false;
                }
            })
        }
    }

    $(function(){
        $(".ct-choose").click(function(){
            var ctId = $(this).attr("data-id");
            localStorage.setItem(_Car.STORAGEKEY.selectedInvoice,ctId);
            mui.openWindow({
                createNew : false,
                url : "shoppingcar.do?goBuy&invoiceId="+ctId+"&commonAddressId="+localStorage.getItem("commonAddressId")
            })
        })

        $(".checkbox1").click(function(){
            var $this = $(this);
            if($(this).is(":checked")){
                $.post("cbsInvoiceInfoController.do?setAsDefault",{id:$(this).parents("li").attr("data-id")},function(data){
                    $(".checkbox1").not($this).removeAttr("checked");
                    $(".checkbox1").not($this).next().html(setDefault);
                    $this.next().html(defaultText)
                })
            }else{
                return false;
            }
        })

        $(".ct-edit").click(function(){
            var id = $(this).parents("li").attr("data-id");
            mui.openWindow({
                createNew : true,
                url :"cbsInvoiceInfoController.do?goWxAdd&id="+id
            })
            return false;
        })

        $(".ct-del").click(function() {
            var id = $(this).parents("li").attr("data-id");
            var $this = $(this);
            mui.confirm("确认删除此条发票信息吗", "提示", function (idx) {
                if (idx.index == 1) {
                    $.post("cbsInvoiceInfoController.do?doDel", {id: id}, function (data) {
                        if (data.success) {
                            $this.parents("li").remove();
                        }
                    })
                }
            })
            return false;
        })
    })

    $(function () {
        mui('.mui-scroll-wrapper').scroll({
            deceleration: 0.0005
        });



        $("#btn_confirm").click(function () {
        	var cinemaid = '${cinema}';
            if($("li").size() > 9){
                mui.alert("您的发票信息已达上限，删除原有信息才可以添加新信息",'提示');
                return;
            }
            mui.openWindow({
                createNew : true,
                url : "cbsInvoiceInfoController.do?goWxAdd&cinemaid="+cinemaid
            })
        })
    })

</script>
</body>
</html>